package com.yocky.eventutilsdemo;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.yocky.eventutilsdemo.event.EventMsg;
import com.yocky.eventutilsdemo.event.EventUtils;
import com.yocky.eventutilsdemo.event.Observers;

/**
 * @name：
 * @author： 杨 广
 * @phone： 17382373271
 * @createTime： 2017/3/27
 * @modifyTime： 2017/3/27
 * @explain：
 */

public class TestAc extends BaseActivity implements Observers {

    private TextView tv;
    @Override
    protected int getlayoutView() {
        return R.layout.ss;
    }

    @Override
    protected void initView(View view) {
        EventUtils.getDefault().register(this);
        tv= (TextView) view.findViewById(R.id.tv);
        tv.setText("TestAc.class");
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(TestAc.this,TestAct.class));
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void clickListener(View view) {

    }

    @Override
    public void update(Object obj) {
        if (!(obj instanceof EventMsg)){
            return;
        }
        EventMsg eventMsg = (EventMsg) obj;
        tv.setText("message: " + eventMsg.getMsg() + "\nfrom :" + eventMsg.getFrom());

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventUtils.getDefault().unregister(this);
    }


}
